package com.icycandy.blogmover.hi2wp;

import org.dom4j.Document;
import org.dom4j.DocumentHelper;
import org.dom4j.Element;

/**
 * 
 * @author icycandy
 */
public class Comment
{
	private int id;
	private String name;
	private String date;
	private String url;
	private String email;
	private String content;
	
	public Comment(int id, String name, String date, String url, String email, String content)
	{
		this.id = id;
		this.name = name;
		this.date = date;
		this.url = url;
		this.email = email;
		this.content = content;
	}
	
	public Element toXml()
	{
		Document document = DocumentHelper.createDocument();
		Element root = document.addElement("wp:comment");
		
		root.addNamespace("excerpt", "http://wordpress.org/export/1.0/excerpt/");
		root.addNamespace("content", "http://purl.org/rss/1.0/modules/content/");
		root.addNamespace("wfw", "http://wellformedweb.org/CommentAPI/");
		root.addNamespace("dc", "http://purl.org/dc/elements/1.1/");
		root.addNamespace("wp", "http://wordpress.org/export/1.0/");
		
		Element tmp = root.addElement("wp:comment_id");
		tmp.addText(Integer.toString(id));
		
		tmp = root.addElement("wp:comment_author");
		tmp.addCDATA(name);
		
		tmp = root.addElement("wp:comment_author_email");
		tmp.addText(email);
		
		tmp = root.addElement("wp:comment_author_url");
		tmp.addText(url);
		
		tmp = root.addElement("wp:comment_date");
		tmp.addText(date);
		
		tmp = root.addElement("wp:comment_date_gmt");
		tmp.addText(date);
		
		tmp = root.addElement("wp:comment_content");
		tmp.addCDATA(content);
		
		tmp = root.addElement("wp:comment_approved");
		tmp.addText("1");
		
		tmp = root.addElement("wp:comment_type");
		
		tmp = root.addElement("wp:comment_parent");
		tmp.addText("0");
		
		tmp = root.addElement("wp:comment_user_id");
		tmp.addText("0");
		
		return root;
	}
	
	public static void main(String[] args)
	{
		
	}
}
